package com.example.wiki3.Dao;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


public class DatabaseHelper extends SQLiteOpenHelper {
    // 数据库名称
    private static final String DATABASE_NAME = "wiki.db";
    // 数据库版本号
    private static final int DATABASE_VERSION = 1;

    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // 创建表的SQL语句
        String CREATE_TABLE = "CREATE TABLE book_content (id LONG PRIMARY KEY, name TEXT, ebookId INTEGER ,content STRING,viewCount INTEGER,voteCount INTEGER , sort int(8))";
        db.execSQL(CREATE_TABLE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // 更新表结构时执行的逻辑，这里可以添加修改表结构的SQL语句
        db.execSQL("DROP TABLE IF EXISTS book_content");
        onCreate(db);
    }
}